/**
 * 功能描述 联盟团信息导航条
 */

define(function (require, exports, module) {
	var Subnav = require("subnav");
	
	var subnavEvents = require("../handler/subnavEvents");
	
    var instance = {
        initComponent: function (params, widget) {
            var subnav = new Subnav({
            	parentNode : ".J-subnav",
            	model : {
        			title : "联盟团信息",
        			items:[{
        				id : "status",
        				type : "buttongroup",
        				tip : "状态",
        				items:[{
        					key : "All",
        					value : "全部"
        				},{
        					key : "Reserve",
        					value : "已预约"
        				},{
        					key : "Initial",
        					value : "待预约"
        				}],
        				handler:function(key,element){
				    	  widget.get("grid").refresh();
        				}
        			},{
						id : "startDate",
						type : "daterange",
						ranges : {
					        "本年": [moment().startOf("year"), moment().endOf("days")],
					        "本月": [moment().startOf("month"), moment().endOf("month")]
						},
						tip : "开始日期",
						handler : function(time){
							 widget.get("grid").refresh();
						}
					},{
        				id:"add",
        				type:"button",
        				text:"新增",
        				handler:function(){
        					widget.get("form").reset();
        					widget.get("editgrid").setData([]);
        					widget.get("roomeditgrid").setData([]);
        					widget.show([".J-form",".J-roomeditgrid",".J-editgrid"]).hide([".J-grid"]);
							widget.get("subnav").hide(["add", "status", "startDate"]).show(["save", "return"]);
        				}
        			},{
        				id : "save",
						type : "button",
						text : "保存",						
						show : false,
						handler:function(){
							subnavEvents.saveAction(widget);
						}
        			},{
        				id : "return",
						type : "button",
						text : "返回",						
						show : false,
						handler:function(){
							widget.show([".J-grid"]).hide([".J-roomeditgrid",".J-form",".J-editgrid", ".J-detailgrid"]);
							widget.get("subnav").hide(["save", "return"]).show(["add","status", "startDate"]);
							widget.get("grid").refresh();
						}
        			}]
        		}
            })
        	widget.set("subnav", subnav);
        }
    };
    module.exports = instance;
});
